package com.cloudbroker.bcs.common.validatioin.annotation;

import com.cloudbroker.bcs.common.util.DateTimeUtil;
import com.cloudbroker.bcs.common.validatioin.constants.ValidationConstants;
import com.cloudbroker.bcs.common.validatioin.constants.ValidationErrorCodes;
import com.cloudbroker.bcs.common.validatioin.validator.DateValueValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * Created by fangyf18371 on 2017/1/20.
 */

@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = DateValueValidator.class)
public @interface DateValidation {
    Class<?>[] groups() default {};

    String message() default ValidationConstants.MSG_DATE;

    Class<? extends Payload>[] payload() default {};

    String errorCode() default ValidationErrorCodes.PARAM_NOT_DATE;

    /**
     * 指明格式
     * @return
     */
    String pattern() default DateTimeUtil.FORMAT_YYYYMMDD_NO_BREAK;
}
